//
//  BanBu_BloodTypeAndHeightController.m
//  BanBu
//
//  Created by 17xy on 12-8-6.
//
//

#import "BanBu_BloodTypeAndHeightController.h"
#import "BanBu_BirthdayViewController.h"
#import "AppDataManager.h"
#import "TKLoadingView.h"
#import "BanBu_ImageView.h"
#import "BanBu_NavButton.h"
@interface BanBu_BloodTypeAndHeightController ()

@end
NSInteger Wselect = 0;
NSInteger Hselect = 0;
NSInteger Bselect = 0;
@implementation BanBu_BloodTypeAndHeightController
- (id)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if(self.viewType == BloodTypeAndHeightOnlyType)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"noticeNotice", nil) message:NSLocalizedString(@"labelEditedOnce", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }
}
-(void)popself
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    UILabel *lab = (UILabel *)[self.navigationController.navigationBar viewWithTag:10000];
    [lab removeFromSuperview];
    UILabel *lab1 = (UILabel *)[self.navigationController.navigationBar viewWithTag:10001];
    [lab1 removeFromSuperview];
}

-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [super viewWillAppear:YES];
    /*
    NSString *title = nil;
    if(self.viewType == BloodTypeAndHeightOnlyType)
    {
        title = NSLocalizedString(@"bodyAndBloodTitle", nil);
    }
    else
    {
        title = [NSString stringWithFormat:@"%@(3/5)",NSLocalizedString(@"bodyAndBloodTitle", nil)];
    }
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 44)];
    lab.text = title;
    lab.lineBreakMode = kTextLineBreakByWordWrapping;
    [self.navigationController.navigationBar addSubview:lab];
    lab.center = CGPointMake(self.navigationController.navigationBar.frame.size.width/2, 22);
    lab.textAlignment = kTextAlignmentCenter;
    CGFloat height = [lab.text sizeWithFont:[UIFont fontWithName:@"TrebuchetMS-Bold" size:18] constrainedToSize:CGSizeMake(150, 44) lineBreakMode:kTextLineBreakByWordWrapping].height;
    lab.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:height>21?15:18];
    lab.backgroundColor = [UIColor clearColor];
    lab.numberOfLines = 2;
    lab.textColor = [UIColor whiteColor];
    lab.tag = 10000;
    [lab release];
    */
    NSString *title = nil;
    if(self.viewType == BloodTypeAndHeightOnlyType)
    {
        title = NSLocalizedString(@"bodyAndBloodTitle", nil);
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 44)];
        lab.text = title;
        lab.lineBreakMode = kTextLineBreakByWordWrapping;
        [self.navigationController.navigationBar addSubview:lab];
        lab.center = CGPointMake(self.navigationController.navigationBar.frame.size.width/2, 22);
        lab.textAlignment = kTextAlignmentCenter;
        CGFloat height = [lab.text sizeWithFont:[UIFont fontWithName:@"TrebuchetMS-Bold" size:18] constrainedToSize:CGSizeMake(150, 44) lineBreakMode:kTextLineBreakByWordWrapping].height;
        lab.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:height>21?15:18];
        lab.backgroundColor = [UIColor clearColor];
        lab.numberOfLines = 2;
        lab.textColor = [UIColor whiteColor];
        lab.tag = 10000;
        [lab release];
    }
    else
    {
        title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"bodyAndBloodTitle", nil)];
        
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160,22)];
        lab.text = title;
        lab.lineBreakMode = kTextLineBreakByTruncatingTail;
        [self.navigationController.navigationBar addSubview:lab];
        lab.center = CGPointMake(160, 11);
        lab.textAlignment = kTextAlignmentCenter;
        lab.backgroundColor = [UIColor clearColor];
        lab.textColor = [UIColor whiteColor];
        lab.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:15];
        lab.tag = 10000;
        [lab release];
        
        
        UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 22)];
        lab1.center = CGPointMake(160, 33);
        lab1.text = @"(3/5)";
        [self.navigationController.navigationBar addSubview:lab1];
        lab1.textAlignment = kTextAlignmentCenter;
        lab1.backgroundColor = [UIColor clearColor];
        lab1.textColor = [UIColor whiteColor];
        lab1.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:15];
        lab1.tag = 10001;
        [lab1 release];

    }

    
    
    
    
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];

//    self.view.backgroundView = nil;
    self.view.backgroundColor = [UIColor colorWithRed:255.0/255 green:250.0/255 blue:240.0/255 alpha:1.0];
//    self.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"bodyAndBloodTitle", nil)];
    self.navigationItem.leftBarButtonItem.title = @"＜2/5";
    
    BanBu_ImageView *img = [[[BanBu_ImageView alloc]initWithBackGroundImageType:UIImageViewCreatTypeTable] autorelease];
    self.view.backgroundColor = [UIColor colorWithPatternImage:img.image];
    
    if(self.viewType == BloodTypeAndHeightFullType)
    {
        BOOL isMan = [[MyAppDataManager.regDic valueForKey:@"gender"] isEqualToString:@"m"];

        BanBu_NavButton *backButton = [[BanBu_NavButton alloc] initWithButtonType:UIButtonCreatTypeNormal];
        backButton.position = ButtonPositionLeft;
        backButton.frame=CGRectMake(0, 0, 60, 30);
        [backButton addTarget:self action:@selector(popself) forControlEvents:UIControlEventTouchUpInside];
        
        [backButton setTitle:@"＜2/5" forState:UIControlStateNormal];
//        backButton.titleLabel.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:18];
        backButton.titleLabel.font = [UIFont systemFontOfSize:18];
        UIBarButtonItem *back = [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];
        back.style = UIBarButtonItemStylePlain;
        self.navigationItem.leftBarButtonItem = back;
        [backButton release];
        
        BanBu_NavButton *nextButton = [[BanBu_NavButton alloc] initWithButtonType:UIButtonCreatTypeNormal];
        nextButton.position = ButtonPositionRight;
        nextButton.frame=CGRectMake(0, 0, 60, 30);
        [nextButton addTarget:self action:@selector(nextStep:) forControlEvents:UIControlEventTouchUpInside];
        [nextButton setTitle:@"4/5＞" forState:UIControlStateNormal];
//        nextButton.titleLabel.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:18];
        nextButton.titleLabel.font = [UIFont systemFontOfSize:18];
        UIBarButtonItem *next = [[[UIBarButtonItem alloc] initWithCustomView:nextButton] autorelease];
        self.navigationItem.rightBarButtonItem = next;
        [nextButton release];
        CGSize size = [NSLocalizedString(@"changeNotice", nil) sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(300, 1000) lineBreakMode:kTextLineBreakByWordWrapping];
        
        UIView *roundView = [[UIView alloc] initWithFrame:CGRectMake(5, 20, 310, 42+size.height)];
        roundView.layer.cornerRadius = 8.0;
        roundView.layer.borderWidth = 0.8;
        roundView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        roundView.backgroundColor = [UIColor whiteColor];
        
        UILabel *tipLabel= [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 310, 20)];
        tipLabel.backgroundColor = [UIColor clearColor];
        tipLabel.textAlignment = kTextAlignmentCenter;
        tipLabel.textColor = [UIColor blackColor];
        tipLabel.font = [UIFont boldSystemFontOfSize:16];
        tipLabel.text = NSLocalizedString(@"helpfulTitle", nil);
        [roundView addSubview:tipLabel];
        [tipLabel release];
        
        UILabel *helpLabel= [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 310, size.height)];
        helpLabel.backgroundColor = [UIColor clearColor];
        helpLabel.textAlignment = kTextAlignmentCenter;
        helpLabel.numberOfLines = 2;
        helpLabel.textColor = [UIColor darkGrayColor];
        helpLabel.font = [UIFont boldSystemFontOfSize:16];
        helpLabel.text = NSLocalizedString(@"changeNotice", nil);
        [roundView addSubview:helpLabel];
        [helpLabel release];
        [self.view addSubview:roundView];
        [roundView release];
        
        //    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(5, 62, 310, 1.0)];
        //    lineView.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
        //    [self.view addSubview:lineView];
        //    [lineView release];
        
        UILabel *heightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 80+size.height, 320, 20)];
        heightLabel.backgroundColor = [UIColor clearColor];
        heightLabel.textAlignment = kTextAlignmentLeft;
        heightLabel.textColor = [UIColor darkGrayColor];
        heightLabel.font = [UIFont boldSystemFontOfSize:16];
        heightLabel.text = NSLocalizedString(@"heightLabel", nil);
        [self.view addSubview:heightLabel];
        [heightLabel release];
        
        NSArray *items = [NSArray arrayWithObjects:
                          @"<165",@"165-170",@"170-175",@"175-180",@">180",nil];
        SVSegmentedControl *seg = [[SVSegmentedControl alloc] initWithSectionTitles:items];
        
        //    seg.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg.center = CGPointMake(160, 140+size.height);
        seg.crossFadeLabelsOnDrag = YES;
        //	seg.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        [seg.thumb setTintColor:[UIColor lightGrayColor]];
        seg.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        seg.selectedIndex = isMan?3:1;
        _heightSeg = seg;
        [seg addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg];
        [seg release];
        
        UILabel *bloodLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,185+size.height, 320, 20)];
        bloodLabel.backgroundColor = [UIColor clearColor];
        bloodLabel.textAlignment = kTextAlignmentLeft;
        bloodLabel.textColor = [UIColor darkGrayColor];
        bloodLabel.font = [UIFont boldSystemFontOfSize:16];
        bloodLabel.text = NSLocalizedString(@"bloodLabel", nil);
        [self.view addSubview:bloodLabel];
        [bloodLabel release];
        
        SVSegmentedControl *seg1 = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"A",@"B",@"O",@"AB",nil]];
        //    seg1.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg1.center = CGPointMake(160, 245+size.height);
        seg1.crossFadeLabelsOnDrag = YES;
        seg1.selectedIndex = 2;
        //    seg1.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        //    seg1.thumb.tintColor = [UIColor colorWithWhite:0 alpha:.3];
        [seg1.thumb setTintColor:[UIColor lightGrayColor]];
        seg1.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        _bloodtypeSeg = seg1;
        [seg1 addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg1];
        [seg1 release];
        
        UILabel *wightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 290+size.height, 320, 20)];
        wightLabel.backgroundColor = [UIColor clearColor];
        wightLabel.textAlignment = kTextAlignmentLeft;
        wightLabel.textColor = [UIColor darkGrayColor];
        wightLabel.font = [UIFont boldSystemFontOfSize:16];
        wightLabel.text = NSLocalizedString(@"wightLabel", nil);
        [self.view addSubview:wightLabel];
        [wightLabel release];
        
        SVSegmentedControl *seg2 = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"<40",@"40-50",@"50-60",@"60-70",@">70",nil]];
        //    seg2.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg2.center = CGPointMake(160, 340+size.height);
        seg2.crossFadeLabelsOnDrag = YES;
        seg2.selectedIndex = isMan?3:1;
        //    seg2.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        //    seg2.thumb.tintColor = [UIColor colorWithWhite:0 alpha:.3];
        [seg2.thumb setTintColor:[UIColor lightGrayColor]];
        seg2.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        _wightSeg = seg2;
        [seg2 addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg2];
        [seg2 release];

    }
    else
    {
//        BanBu_NavButton *backButton = [[BanBu_NavButton alloc] initWithButtonType:UIButtonCreatTypeNormal];
//        backButton.position = ButtonPositionLeft;
//        backButton.frame=CGRectMake(0, 0, 60, 30);
//        [backButton addTarget:self action:@selector(popself) forControlEvents:UIControlEventTouchUpInside];
//        
//        //    [backButton setTitleEdgeInsets:UIEdgeInsetsMake(3, 2, 2, 2)];
//        [backButton setTitle:NSLocalizedString(@"returnButton",nil) forState:UIControlStateNormal];
//        backButton.titleLabel.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:18];
//        UIBarButtonItem *back = [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];
//        back.style = UIBarButtonItemStylePlain;
//        self.navigationItem.leftBarButtonItem = back;
//        [backButton release];
        
        BanBu_NavButton *nextButton = [[BanBu_NavButton alloc] initWithButtonType:UIButtonCreatTypeNormal];
        nextButton.position = ButtonPositionRight;
        nextButton.frame=CGRectMake(0, 0, 60, 30);
        [nextButton addTarget:self action:@selector(ConfirmSelect) forControlEvents:UIControlEventTouchUpInside];
        //    [nextButton setTitleEdgeInsets:UIEdgeInsetsMake(3, 2, 2, 2)];
        [nextButton setTitle:NSLocalizedString(@"确定",nil) forState:UIControlStateNormal];
        nextButton.titleLabel.font = [UIFont  fontWithName:@"TrebuchetMS-Bold" size:18];
        UIBarButtonItem *next = [[[UIBarButtonItem alloc] initWithCustomView:nextButton] autorelease];
        self.navigationItem.rightBarButtonItem = next;
        [nextButton release];
        CGSize size = [NSLocalizedString(@"changeNotice", nil) sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(300, 1000) lineBreakMode:kTextLineBreakByWordWrapping];
        
        UIView *roundView = [[UIView alloc] initWithFrame:CGRectMake(5, 20, 310, 42+size.height)];
        roundView.layer.cornerRadius = 8.0;
        roundView.layer.borderWidth = 0.8;
        roundView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        roundView.backgroundColor = [UIColor whiteColor];
        
        UILabel *tipLabel= [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 310, 20)];
        tipLabel.backgroundColor = [UIColor clearColor];
        tipLabel.textAlignment = kTextAlignmentCenter;
        tipLabel.textColor = [UIColor blackColor];
        tipLabel.font = [UIFont boldSystemFontOfSize:16];
        tipLabel.text = NSLocalizedString(@"helpfulTitle", nil);
        [roundView addSubview:tipLabel];
        [tipLabel release];
        
        UILabel *helpLabel= [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 310, size.height)];
        helpLabel.backgroundColor = [UIColor clearColor];
        helpLabel.textAlignment = kTextAlignmentCenter;
        helpLabel.numberOfLines = 2;
        helpLabel.textColor = [UIColor darkGrayColor];
        helpLabel.font = [UIFont boldSystemFontOfSize:16];
        helpLabel.text = NSLocalizedString(@"changeNotice", nil);
        [roundView addSubview:helpLabel];
        [helpLabel release];
        [self.view addSubview:roundView];
        [roundView release];
        
        //    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(5, 62, 310, 1.0)];
        //    lineView.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
        //    [self.view addSubview:lineView];
        //    [lineView release];
        
        UILabel *heightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 80+size.height, 320, 20)];
        heightLabel.backgroundColor = [UIColor clearColor];
        heightLabel.textAlignment = kTextAlignmentLeft;
        heightLabel.textColor = [UIColor darkGrayColor];
        heightLabel.font = [UIFont boldSystemFontOfSize:16];
        heightLabel.text = NSLocalizedString(@"heightLabel", nil);
        [self.view addSubview:heightLabel];
        [heightLabel release];
        
        NSArray *items = [NSArray arrayWithObjects:
                          @"<165",@"165-170",@"170-175",@"175-180",@">180",nil];
        SVSegmentedControl *seg = [[SVSegmentedControl alloc] initWithSectionTitles:items];
        
        //    seg.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg.center = CGPointMake(160, 140+size.height);
        seg.crossFadeLabelsOnDrag = YES;
        //	seg.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        [seg.thumb setTintColor:[UIColor lightGrayColor]];
        seg.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        seg.selectedIndex = Hselect;
        _heightSeg = seg;
        [seg addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg];
        [seg release];
        
        UILabel *bloodLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,185+size.height, 320, 20)];
        bloodLabel.backgroundColor = [UIColor clearColor];
        bloodLabel.textAlignment = kTextAlignmentLeft;
        bloodLabel.textColor = [UIColor darkGrayColor];
        bloodLabel.font = [UIFont boldSystemFontOfSize:16];
        bloodLabel.text = NSLocalizedString(@"bloodLabel", nil);
        [self.view addSubview:bloodLabel];
        [bloodLabel release];
        
        SVSegmentedControl *seg1 = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"A",@"B",@"O",@"AB",nil]];
        //    seg1.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg1.center = CGPointMake(160, 245+size.height);
        seg1.crossFadeLabelsOnDrag = YES;
        seg1.selectedIndex = Bselect;
        //    seg1.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        //    seg1.thumb.tintColor = [UIColor colorWithWhite:0 alpha:.3];
        [seg1.thumb setTintColor:[UIColor lightGrayColor]];
        seg1.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        _bloodtypeSeg = seg1;
        [seg1 addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg1];
        [seg1 release];
        
        UILabel *wightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 290+size.height, 320, 20)];
        wightLabel.backgroundColor = [UIColor clearColor];
        wightLabel.textAlignment = kTextAlignmentLeft;
        wightLabel.textColor = [UIColor darkGrayColor];
        wightLabel.font = [UIFont boldSystemFontOfSize:16];
        wightLabel.text = NSLocalizedString(@"wightLabel", nil);
        [self.view addSubview:wightLabel];
        [wightLabel release];
        
        SVSegmentedControl *seg2 = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"<40",@"40-50",@"50-60",@"60-70",@">70",nil]];
        //    seg2.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
        seg2.center = CGPointMake(160, 340+size.height);
        seg2.crossFadeLabelsOnDrag = YES;
        seg2.selectedIndex = Wselect;
        //    seg2.thumb.tintColor = [UIColor colorWithRed:0.6 green:0.2 blue:0.2 alpha:1];
        //    seg2.thumb.tintColor = [UIColor colorWithWhite:0 alpha:.3];
        [seg2.thumb setTintColor:[UIColor lightGrayColor]];
        seg2.backgroundColor = [UIColor colorWithWhite:0 alpha:.2];
        _wightSeg = seg2;
        [seg2 addTarget:self action:@selector(segmentedControlDidChangeValue:) forControlEvents:UIControlEventValueChanged];
        [self.view addSubview:seg2];
        [seg2 release];

    }
   
    
}
-(void)setDefaultSelectIndexHeight:(NSString *)_h Weight:(NSString *)_w Blood:(NSString *)_b;
{
    if([_h isEqualToString:@"160-165"]){Hselect = 1;}
    else
        if([_h isEqualToString:@"165-170"]){Hselect = 2;}
    else
        if([_h isEqualToString:@"170-175"]){Hselect = 3;}
    else
        if([_h isEqualToString:@"> 175"]){Hselect = 4;}
        else {Hselect = 0;}
    
    
    
    if([_w isEqualToString:@"40-50"]){Wselect = 1;}
    else
        if([_w isEqualToString:@"50-60"]){Wselect = 2;}
        else
            if([_w isEqualToString:@"60-70"]){Wselect = 3;}
            else
                if([_w isEqualToString:@"> 70"]){Wselect = 4;}
                else {Wselect = 0;}
    
    
    if([_b isEqualToString:@"B"]){Bselect = 1;}
    else
        if([_b isEqualToString:@"O"]){Bselect = 2;}
        else
            if([_b isEqualToString:@"AB"]){Bselect = 3;}

                else {Bselect = 0;}

}
- (void)segmentedControlDidChangeValue:(UISegmentedControl *)seg
{
//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"小提示"
//                                                    message:@"请确定你的选择，一旦提交无法更改！" delegate:nil
//                                          cancelButtonTitle:@"确定"
//                                          otherButtonTitles:nil, nil];
//    [alert show];
//    [alert release];

//    [TKLoadingView showTkloadingAddedTo:self.view point:CGPointMake(0, 230) title:NSLocalizedString(@"changeNotice", nil) activityAnimated:NO duration:1.0];

    
}
-(void)ConfirmSelect
{
//    NSArray *hArray = [NSArray arrayWithObjects:@"< 160",@"160-165",@"165-170",@"170-175",@"> 175", nil];
//    NSArray *bArray = [NSArray arrayWithObjects:@"A",@"B",@"O",@"AB",nil];
//    NSArray *wArray = [NSArray arrayWithObjects:@"< 40",@"40-50",@"50-60", @"60-70",@"> 70",nil];
    
    NSString *typeStr = @"abocx";
    NSString *hStr = @"abcde";
    NSString *wStr = @"abcde";
    
    
    if([_delegate respondsToSelector:@selector(banBuTextEditerDidChangeValue:forItem:)])
    {
        [_delegate banBuTextEditerDidChangeValue:[hStr substringWithRange:NSMakeRange(_heightSeg.selectedIndex, 1)] forItem:NSLocalizedString(@"s1c0", nil)];
        [_delegate banBuTextEditerDidChangeValue:[wStr substringWithRange:NSMakeRange(_wightSeg.selectedIndex, 1)]  forItem:NSLocalizedString(@"s1c2", nil)];
        [_delegate banBuTextEditerDidChangeValue:[typeStr substringWithRange:NSMakeRange(_bloodtypeSeg.selectedIndex, 1)] forItem:NSLocalizedString(@"s1c1", nil)];
    }
    [self popself];
}
- (void)nextStep:(UIButton *)button
{
    NSArray *hArray = [NSArray arrayWithObjects:@"< 160",@"160-165",@"165-170",@"170-175",@"> 175", nil];
    NSArray *bArray = [NSArray arrayWithObjects:@"A",@"B",@"O",@"AB",nil];
    NSArray *wArray = [NSArray arrayWithObjects:@"< 40",@"40-50",@"50-60", @"60-70",@"> 70",nil];
    
    NSMutableString *str1 = [NSMutableString stringWithFormat:@"%@%@ cm",NSLocalizedString(@"selectHeight", nil]),[hArray objectAtIndex:_heightSeg.selectedIndex]];
    NSMutableString *str2 = [NSMutableString stringWithFormat:@"%@%@",NSLocalizedString(@"selectBlood", nil]),[bArray objectAtIndex:_bloodtypeSeg.selectedIndex]];
    NSMutableString *str3 = [NSMutableString stringWithFormat:@"%@%@ kg",NSLocalizedString(@"selectWeight", nil]),[wArray objectAtIndex:_wightSeg.selectedIndex]];

    NSString *information = [NSString stringWithFormat:@"%@\n%@\n%@",str1,str2,str3];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"helpfulTitle", nil) message:information delegate:self cancelButtonTitle:NSLocalizedString(@"editSex", nil)  otherButtonTitles:NSLocalizedString(@"确定", nil),nil];
    alert.tag = 138;
    [alert show];
    [alert release];
}
-(void)willPresentAlertView:(UIAlertView *)alertView
{
    {
        for( UIView * view in alertView.subviews )
        {
            if( [view isKindOfClass:[UILabel class]] )
            {
                UILabel* label = (UILabel*) view;
                if(![label.text isEqualToString:NSLocalizedString(@"helpfulTitle", nil)])
                {
                    label.textAlignment=kTextAlignmentLeft;
                }
            }
        }
    }
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(alertView.tag == 138)
    {
        if(buttonIndex == 0)
        {
            
        }
        if(buttonIndex == 1)
        {
            [self pushNext];
        }
    }
}
#pragma mark - 保存数据到MyAppDataManager 参数"blood" "hbody" "wbody"
-(void)saveRegisterInfo:(NSString *)_blood and:(NSString *)_hbody and:(NSString *)_wbody
{
    [MyAppDataManager.regDic setValue:_blood forKey:@"blood"];
    [MyAppDataManager.regDic setValue:_hbody forKey:@"hbody"];
    [MyAppDataManager.regDic setValue:_wbody forKey:@"wbody"];
}

-(void)pushNext
{
    NSString *typeStr = @"abocx";
    NSString *hStr = @"abcde";
    NSString *wStr = @"abcde";

    [self saveRegisterInfo:[typeStr substringWithRange:NSMakeRange(_bloodtypeSeg.selectedIndex, 1)] and:[hStr substringWithRange:NSMakeRange(_heightSeg.selectedIndex, 1)] and:[wStr substringWithRange:NSMakeRange(_wightSeg.selectedIndex, 1)]];

    BanBu_BirthdayViewController *birthday = [[BanBu_BirthdayViewController alloc] init];
    [self.navigationController pushViewController:birthday animated:YES];
    [birthday release];
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
-(void)dealloc
{
    [super dealloc];

}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
